import mycode.ReadDICOM
import mycode.ReadNRRD
import mycode.ReadNIFTI
import os


def run(path):
    for dirName, subdirList, fileList in os.walk(path):
        for filename in fileList:
            # 将文件中后缀名为.dcm的文件名加到路径中，然后存入lstFilesDCM
            if '.dcm' in filename.lower():
                dpp = mycode.ReadDICOM.DataPreProcess(path)
            elif '.nrrd' in filename.lower():
                dpp = mycode.ReadNRRD.DataPreProcess(path)
            else:
                dpp = mycode.ReadNIFTI.DataPreProcess(path)
            dpp.run()
            return True


if __name__ == '__main__':
    path_ = './dataset/'
    # run(path_ + 'nrrd_heart/nrrd_heart')

    run('mycode')